﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using VPC.BO;
using VPC.BL;

namespace VPC.UI
{
    public partial class LoginForm : Form
    {
        public LoginForm()
        {
            InitializeComponent();
        }

        private void buttonLogin_Click(object sender, EventArgs e)
        {
            if (textBoxUName.Text == "")
            {
                MessageBox.Show("Username can't be empty");
            }
            else if (textBoxPwd.Text == "")
            {
                MessageBox.Show("Password can't be empty");
            }

            else
            {
                UserBO objUserBO = new UserBO();
                objUserBO.Username = textBoxUName.Text;
                objUserBO.Password = textBoxPwd.Text;
                        
                UserBL objUserBL = new UserBL();

                Boolean status = objUserBL.DoLoginValidation(objUserBO);

                if (status == true)
                {
                    WelcomeForm frmWelcome = new WelcomeForm();
                    this.Hide();
                    frmWelcome.ShowDialog();
                }

                else
                {
                    MessageBox.Show("Invalid login or password. Please try again.");
                }
            }

        }

        private void registerToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Registercs frmRegister = new Registercs();
            frmRegister.ShowDialog();
        }
    }
}
